package com.nantai.jiafang.nantaijiafang.deviceManager.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.nantai.jiafang.nantaijiafang.R;
import com.nantai.jiafang.nantaijiafang.deviceManager.bean.TaskDetail.DetailBean;

import java.util.List;

/**
 * Created by xxfreedom on 2017/2/12.
 */

public class TaskDetailAdapter extends BaseAdapter {
    private List<DetailBean> taskList;
    private LayoutInflater inflater;
    public TaskDetailAdapter() {}

    public TaskDetailAdapter(List<DetailBean> taskList, Context context) {
        this.taskList = taskList;
        this.inflater=LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return taskList==null?0:taskList.size();
    }

    @Override
    public DetailBean getItem(int position) {
        return taskList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        //加载布局为一个视图
        View view=inflater.inflate(R.layout.task_detail_item,null);
        DetailBean device=getItem(position);
        TextView tv_name= (TextView) view.findViewById(R.id.deviceName_tv);
        TextView tv_code= (TextView) view.findViewById(R.id.deviceCode_tv);
        TextView tv_oldplace= (TextView) view.findViewById(R.id.oldPlace_tv);
        TextView tv_place= (TextView) view.findViewById(R.id.place_tv);
        TextView tv_time= (TextView) view.findViewById(R.id.time_tv);
        TextView tv_user= (TextView) view.findViewById(R.id.user_tv);
        tv_name.setText("设备名称:"+device.getDevice_name());
        tv_code.setText("设备条码:"+device.getDevice_code());
        tv_oldplace.setText("旧库位:"+device.getOld_place());
        tv_place.setText("新库位:"+device.getPlace_name());
        tv_time.setText("盘点时间:"+device.getCreate_time());
        tv_user.setText("盘点人:"+device.getUsername());
        return view;
    }
    public void updateItem(int position)
    {

    }
}
